package com.jiamao.goplay.ui.discover.vm;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.jiamao.goplay.BR;
import com.jiamao.goplay.R;

import java.util.ArrayList;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.MultiItemViewModel;
import me.tatarka.bindingcollectionadapter2.ItemBinding;
import me.tatarka.bindingcollectionadapter2.OnItemBind;

public class CityItemVM extends MultiItemViewModel {

    //用户名的绑定
    public ObservableField<String> title = new ObservableField<>("");

    public ObservableList<MultiItemViewModel> observableList = new ObservableArrayList<>();

    public ObservableField<Boolean> select = new ObservableField<>();

    public CityItemVM(@NonNull BaseViewModel viewModel, String name, ArrayList<String> list) {
        super(viewModel);
        title.set(name);
        select.set(false);
        for (String arr:list){
            observableList.add(new CityItemTextVM(viewModel,arr));
        }
    }

    //RecyclerView多布局添加ItemBinding
    public ItemBinding<MultiItemViewModel> itemBinding = ItemBinding.of(new OnItemBind<MultiItemViewModel>() {
        @Override
        public void onItemBind(ItemBinding itemBinding, int position, MultiItemViewModel item) {
            //通过item的类型, 动态设置Item加载的布局

                itemBinding.set(BR.viewModel, R.layout.discover_city_item_text_layout);

        }
    });





}
